home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
lisp
/
eulisp
/
mpfeel.lha
/
MPFeel
/
Plurals
/
Modules
/
tori.em
< prev
Wrap
Lisp/Scheme
|
1992-06-04
|
1KB
|
40 lines
(defmodule tori (standard0 ppl plural) ()
(defconstant N 0)
(defconstant E 1)
(defconstant S 2)
(defconstant W 3)
(defconstant NE 4)
(defconstant NW 5)
(defconstant SE 6)
(defconstant SW 7)
(defun inverse (map)
(match (index map) (move (index map) map cons ())))
(defun make-bi-torus (w h)
(let ((new (make-paralation (* w h)))
(shape-vec (make-vector 8)))
((setter vector-ref) shape-vec N
(match new (elwise (new) (remainder (+ new w) (* w h)))))
((setter vector-ref) shape-vec S (inverse (vector-ref shape-vec N)))
((setter vector-ref) shape-vec E
(match new (elwise (new) (let ((tmp (remainder new w)))
(if (eq tmp 0) (+ new (- w 1)) (- new 1))))))
((setter vector-ref) shape-vec W (inverse (vector-ref shape-vec E)))
((setter vector-ref) shape-vec NE
(match (move (move new (vector-ref shape-vec N) cons ())
(vector-ref shape-vec E) cons ()) new))
((setter vector-ref) shape-vec SW (inverse (vector-ref shape-vec NE)))
((setter vector-ref) shape-vec NW
(match (move (move new (vector-ref shape-vec N) cons ())
(vector-ref shape-vec W) cons ()) new))
((setter vector-ref) shape-vec SE (inverse (vector-ref shape-vec NW)))
((setter shape) new shape-vec)
new))
(export N S E W NE NW SE SW make-bi-torus)
)